$(function () {
    var time = new Date();
    var y = time.getFullYear();
    var m = time.getMonth()+1;
    var d = time.getDate();
    if(m<10){m = "0"+m}
    if(d<10){d = "0"+d}
    $("#revisitTime").val(y + "-" + m + "-" + d)
});

function addsf() {
    var index = layer.open({
        type: 2,
        title: '&nbsp',
        area: ['40%', '40%'],
        fix: true,
        maxmin: true,
        content: Feng.ctxPath + '/doctorLooked/to_addsf/'
    });
    this.layerIndex = index;
}

function addjg() {
    var index = layer.open({
        type: 2,
        title: '&nbsp',
        area: ['40%', '40%'],
        fix: true,
        maxmin: true,
        content: Feng.ctxPath + '/doctorLooked/to_addjg/'
    });
    this.layerIndex = index;
}

subsequent = function (id) {
    var index = layer.open({
        type: 2,
        title: '复诊预约',
        area: ['70%', '95%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/doctorLooked/subsequent_info/' + id + '/2',
    });
    this.layerIndex = index;
};

submit.onclick = function() {
    var doctor= document.getElementById("doctorsf").value;   //医生
    var createName= document.getElementById("createName").value;  //创建人
    var revisit= document.getElementById("revisit").value;  //随访人员
    var remarks= document.getElementById("remarks2").value;   //随访内容
    var revisitContent= document.getElementById("revisitContent").value;   //随访结果
    var reservationsId= document.getElementById("reservationsId").value;   //预约id
    var customerId= document.getElementById("customerId").value;   //客户id
    var revisitTime= document.getElementById("revisitTime").value;   //随访时间
    var arrivalStore= document.getElementById("arrivalStore").value;   //门诊
    if(revisitTime == "" || revisitTime == null){
        alert("请选择随访时间！");
        return;
    }
    if((doctor==null||doctor=="") && (revisit==null||revisit=="")){
        alert("请选择医生或随访人员!");
        return;
    }
    if(remarks == "" || remarks == null){
        alert("请添加随访内容！");
        return;
    }
    $.ajax({
        url: Feng.ctxPath + "/doctorLooked/addDoctorContent2",
        type: "post",
        data: {
            doctor: doctor,
            revisitTime: revisitTime,
            createName:createName,
            remarks: remarks,
            revisitContent:revisitContent,
            arrivalStore:arrivalStore,
            customerId:customerId,
            reservationsId: reservationsId,
            revisit:revisit
        },
        success: function (data) {
            if (confirm("现在去新建预约?")) {
                window.parent.DoctorLooked.search();
                subsequent(customerId);
            }else {
                Feng.success('操作成功!');
                window.location.href= Feng.ctxPath + '/doctorLooked/doctor_seeDiagnosis/' + customerId+'/'+3
            }
        },
        error: function (data) {
            alert('没有权限，请联系管理员!');
        }
    });
}

submit2.onclick = function() {//再随访
    var doctor= document.getElementById("doctorsf").value;   //医生
    var revisit= document.getElementById("revisit").value;  //随访人员
    if((doctor==null||doctor=="") && (revisit==null||revisit=="")){
        alert("请选择医生或随访人员!");
        return;
    }
    var index = layer.open({
        type: 2,
        title: '再随访',
        area: ['25%', '50%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/doctorLooked/doctor_followUp'
    });
    this.layerIndex = index;
}

submit3.onclick = function() {//sui随访完成
    var doctor= document.getElementById("doctorsf").value;   //医生
    var createName= document.getElementById("createName").value;  //创建人
    var revisit= document.getElementById("revisit").value;  //随访人员
    var remarks= document.getElementById("remarks2").value;   //随访内容
    var revisitContent= document.getElementById("revisitContent").value;   //随访结果
    var reservationsId= document.getElementById("reservationsId").value;   //预约id
    var customerId= document.getElementById("customerId").value;   //客户id
    var revisitTime= document.getElementById("revisitTime").value;   //随访时间
    var arrivalStore= document.getElementById("arrivalStore").value;   //门诊
    if(revisitTime == "" || revisitTime == null){
        alert("请选择随访时间！");
        return;
    }
    if((doctor==null||doctor=="") && (revisit==null||revisit=="")){
        alert("请选择医生或随访人员!");
        return;
    }
    if(remarks == "" || remarks == null){
        alert("请添加随访内容！");
        return;
    }
    $.ajax({
        url: Feng.ctxPath + "/doctorLooked/addDoctorContent3",
        type: "post",
        data: {
            doctor: doctor,
            revisitTime: revisitTime,
            createName:createName,
            remarks: remarks,
            revisitContent:revisitContent,
            arrivalStore:arrivalStore,
            customerId:customerId,
            reservationsId: reservationsId,
            revisit:revisit
        },
        success: function (data) {
            if (confirm("现在去新建预约?")) {
                subsequent(customerId);
            }else {
                Feng.success('操作成功!');
                window.parent.DoctorLooked.search();
                window.location.href= Feng.ctxPath + '/doctorLooked/doctor_seeDiagnosis/' + customerId+'/'+3
            }
        },
        error: function (data) {
            alert('没有权限，请联系管理员!');
        }
    });
}

submit4.onclick = function() {//随访未完成
    var doctor= document.getElementById("doctorsf").value;   //医生
    var createName= document.getElementById("createName").value;  //创建人
    var revisit= document.getElementById("revisit").value;  //随访人员
    var remarks= document.getElementById("remarks2").value;   //随访内容
    var revisitContent= document.getElementById("revisitContent").value;   //随访结果
    var reservationsId= document.getElementById("reservationsId").value;   //预约id
    var customerId= document.getElementById("customerId").value;   //客户id
    var revisitTime= document.getElementById("revisitTime").value;   //随访时间
    var arrivalStore= document.getElementById("arrivalStore").value;   //门诊
    if(revisitTime == "" || revisitTime == null){
        alert("请选择随访时间！");
        return;
    }
    if((doctor==null||doctor=="") && (revisit==null||revisit=="")){
        alert("请选择医生或随访人员!");
        return;
    }
    if(remarks == "" || remarks == null){
        alert("请添加随访内容！");
        return;
    }
    $.ajax({
        url: Feng.ctxPath + "/doctorLooked/addDoctorContent4",
        type: "post",
        data: {
            doctor: doctor,
            revisitTime: revisitTime,
            createName:createName,
            remarks: remarks,
            revisitContent:revisitContent,
            arrivalStore:arrivalStore,
            customerId:customerId,
            reservationsId: reservationsId,
            revisit:revisit
        },
        success: function (data) {
            if (confirm("现在去新建预约?")) {
                subsequent(customerId);
            }else {
                Feng.success('操作成功!');
                window.parent.DoctorLooked.search();
                window.location.href= Feng.ctxPath + '/doctorLooked/doctor_seeDiagnosis/' + customerId+'/'+3
            }
        },
        error: function (data) {
            alert('没有权限，请联系管理员!');
        }
    });
}

submit5.onclick = function() {//随访取消
    var doctor= document.getElementById("doctorsf").value;   //医生
    var createName= document.getElementById("createName").value;  //创建人
    var revisit= document.getElementById("revisit").value;  //随访人员
    var remarks= document.getElementById("remarks2").value;   //随访内容
    var revisitContent= document.getElementById("revisitContent").value;   //随访结果
    var reservationsId= document.getElementById("reservationsId").value;   //预约id
    var customerId= document.getElementById("customerId").value;   //客户id
    var revisitTime= document.getElementById("revisitTime").value;   //随访时间
    var arrivalStore= document.getElementById("arrivalStore").value;   //门诊
    if(revisitTime == "" || revisitTime == null){
        alert("请选择随访时间！");
        return;
    }
    if((doctor==null||doctor=="") && (revisit==null||revisit=="")){
        alert("请选择医生或随访人员!");
        return;
    }
    $.ajax({
        url: Feng.ctxPath + "/doctorLooked/addDoctorContent5",
        type: "post",
        data: {
            doctor: doctor,
            revisitTime: revisitTime,
            createName:createName,
            remarks: remarks,
            revisitContent:revisitContent,
            arrivalStore:arrivalStore,
            customerId:customerId,
            reservationsId: reservationsId,
            revisit:revisit
        },
        success: function (data) {
            if (confirm("现在去新建预约?")) {
                subsequent(customerId);
            }else {
                Feng.success('操作成功!');
                window.parent.DoctorLooked.search();
                window.location.href= Feng.ctxPath + '/doctorLooked/doctor_seeDiagnosis/' + customerId+'/'+3
            }
        },
        error: function (data) {
            alert('没有权限，请联系管理员!');
        }
    });
}